package com.zzh.structuredeployment.activity;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.zzh.bridge.page.PageApp;
import com.zzh.bridge_annotation.RouteTag;
import com.zzh.custom.loading.LoadingOperation;
import com.zzh.structuredeployment.R;
import com.zzh.structuredeployment.frag.LoadingFragment;

@RouteTag(PageApp.LOADING)
public class LoadingActivity extends AppCompatActivity {

    private LoadingOperation mLoadingOperation;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_loading);
        getSupportFragmentManager().beginTransaction().add(R.id.rootView, new LoadingFragment()).commit();
        mLoadingOperation = new LoadingOperation(findViewById(R.id.rootView));
        setClick();
    }

    private void setClick() {
        findViewById(R.id.showLoading).setOnClickListener(view -> mLoadingOperation.showLoading());
        findViewById(R.id.showEmpty).setOnClickListener(view -> mLoadingOperation.showEmpty());
        findViewById(R.id.showError).setOnClickListener(view -> mLoadingOperation.showError());
        findViewById(R.id.showSuccess).setOnClickListener(view -> mLoadingOperation.showSuccess());
        findViewById(R.id.showOngoing).setOnClickListener(view -> mLoadingOperation.showOngoing());
    }
}
